/**
 * Created by Administrator on 2017/4/25.
 */
var ChangePwd = require('../changePwd');
var ChangePayPwd = require('../changePayPwd');
var Layer = require('../../../../src/libs/layer');
var Button = require('../../../../src/libs/button');
var UserInfo = React.createClass({
    getDefaultProps:function(){
        return{
                realName:PageDM.realName.value,
                idNum: PageDM.idNum.value,
                phoneNum: PageDM.phoneNum.value,
                ownPwd: PageDM.ownPwd.value,
                payPwd: PageDM.payPwd.value,
                recommendCode: PageDM.recommendCode.value,
                setRealName: PageDM.URL.setRealName,
                setId: PageDM.URL.setId,
                findPwd: PageDM.URL.findPwd,
                bindCard: PageDM.URL.bindCard
        }
    },
    getInitialState: function () {
        return{
            realName:this.props.realName,
            idNum: this.props.idNum,
            phoneNum: this.props.phoneNum,
            ownPwd: this.props.ownPwd,
            payPwd: this.props.payPwd,
            recommendCode: this.props.recommendCode,
            setRealName: this.props.setRealName,
            setId: this.props.setId,
            findPwd: this.props.findPwd,
            bindCard: this.props.bindCard
        }
    },
    changeLoginClick:function () {
        this.refs.loginCode.resetForm();
        PageDM.changeLoginLayer.showDialog();
    },
    changePayClick:function () {
        this.refs.payCode.resetForm();
        PageDM.changePayLayer.showDialog();
    },
    recommendClick:function () {
        PageDM.recommendLayer.showDialog();
    },
    componentDidMount:function () {
        var _this = this;
        UEventHub.on('LayerOpen',function (v) {
            _this.refs[v].layerOpen();

        });
        UEventHub.on('LayerClose',function (v) {
            _this.refs[v].layerClose();
        });
    },
    render: function(){
        var _this = this;
        return (
            <div className="my-info">
                <div className="title-account"><span>个人信息</span></div>
                <div className="item">
                    <div className="list">
                        <i className="iconfont icon-user"></i>
                        <span className="fc-light name">真实姓名：</span>
                        <span className="fc-dark">{_this.state.realName?_this.state.realName:"您还未进行"}</span>
                        {_this.state.realName?'':<a href={_this.state.setRealName} className="fc-link open-bank-layer">实名认证</a>}
                    </div>
                    <div className="list">
                        <i className="iconfont icon-idcard"></i>
                        <span className="fc-light name">身份证号：</span>
                        <span className="fc-dark">{_this.state.idNum?_this.state.idNum:"您还未进行"}</span>
                        {_this.state.idNum?'':<a href={_this.state.setId} className="fc-link open-bank-layer">实名认证</a>}
                    </div>
                    <div className="list">
                        <i className="iconfont icon-mobile"></i>
                        <span className="fc-light name">手<em></em>机：</span>
                        <span className="fc-dark">{_this.state.phoneNum?_this.state.phoneNum:"未绑定"}</span>
                    </div>
                    <div className="list">
                        <i className="iconfont icon-password"></i>
                        <span className="fc-light name">登录密码：</span>
                        <span className="fc-dark">{_this.state.ownPwd ? "******" : "未设置"}</span>
                        <a href="javascript:;" className="fc-link"  onClick={_this.changeLoginClick}>修改</a>
                    </div>
                    <div className="list">
                        <i className="iconfont icon-paypsd"></i>
                        <span className="fc-light name">支付密码：</span>
                        <span className="fc-dark">{_this.state.payPwd ? "******" : "未设置"}</span>
                        <div ref="linkBox">
                            {
                                _this.state.payPwd ?
                                    <div style={{position:"absolute",left:"300px",top:"0"}}>
                                        <a href="javascript:;" className="fc-link open-layer" data-action="layer-pay-password" style={{positon:"relative",left:"0"}} onClick={_this.changePayClick}>修改</a>
                                        <a href={_this.state.findPwd} className="fc-link forget" style={{position:"relative",left:"50px"}}>找回</a>
                                    </div> :
                                    <a href={_this.state.bindCard} className="fc-link">绑卡</a>
                            }
                        </div>
                    </div>
                    <div className="list">
                        <i className="iconfont icon-code"></i>
                        <span className="fc-light name">我的推荐码：</span>
                        <span className="fc-dark">{_this.state.recommendCode.num?_this.state.recommendCode.num:"无"}</span>
                        <a href="javascript:;" className="fc-link open-layer" data-action="layer-recommend" onClick={_this.recommendClick}>详情</a>
                    </div>
                </div>
                <Layer ref={PageDM.changeLoginLayer.dmbind} getContainer="my-info" width="720px"  className="layer-addbank" closeBack={PageDM.changeLoginLayer.closeBack?PageDM.changeLoginLayer.closeBack:''}>
                    <ChangePwd ref="loginCode" title="修改密码" oldPwd={PageDM.loginPwd} newPwd={PageDM.newPwd} checkNewPwd={PageDM.newPwd2} phoneCode={PageDM.phoneCode} getCode={PageDM.getBtnCode}/>
                    <div className="alert-button">
                        <Button className="btn btn-confirm" value="确认" onClick={PageDM.changeLoginLayer.confirmBack} onMouseDown={PageDM.changeLoginLayer.onMouseDown} dmbind={PageDM.changeLoginLayer.dmbind}/>
                        <input type="button" className="btn btn-cancel close" value="取消" onClick={PageDM.changeLoginLayer.cancelBack}/>
                    </div>
                </Layer>
                {/*<Layer ref={PageDM.confirmLayer.dmbind} width="720px"  className="layer-verified-ok" closeBack={PageDM.confirmLayer.closeBack}>
                    <div className="alert-title"><b></b>温馨提示<b></b></div>
                    <div className="alert-content">
                        <p className="tips">身份信息一经认证后将不能再次修改，请确认无误！</p>
                        <p className="fs30">夏飞飞</p>
                        <p className="fs30">421023198802022234</p>
                        <div className="alert-button">
                            <input type="button" value="确认无误" className="btn btn-confirm" onClick={PageDM.confirmLayer.closeBack} />
                            <input type="button" value="取消修改" className="btn btn-cancel close" onClick={PageDM.confirmLayer.closeBack} />
                        </div>
                    </div>
                </Layer>*/}
                <Layer ref={PageDM.changePayLayer.dmbind} getContainer="my-info" width="720px" className="layer-pay" closeBack={PageDM.changePayLayer.closeBack?PageDM.changePayLayer.closeBack:''}>
                    <ChangePayPwd ref="payCode" title="修改支付密码" oldPwd={PageDM.oldPwd} newPwd={PageDM.newPayPwd} checkNewPwd={PageDM.newPayPwd2} phoneCode={PageDM.phonePay} getCode={PageDM.getBtnCode2}/>
                    <div className="alert-button">
                        <Button className="btn btn-confirm" value="确认" onClick={PageDM.changePayLayer.confirmBack} dmbind={PageDM.changePayLayer.dmbind}/>
                        <input type="button" className="btn btn-cancel close" value="取消" onClick={PageDM.changePayLayer.cancelBack}/>
                    </div>
                </Layer>
                <Layer ref={PageDM.recommendLayer.dmbind} getContainer="my-info" width="720px"  className="layer-recommend" closeBack={PageDM.recommendLayer.closeBack?PageDM.recommendLayer.closeBack:''}>
                    <div className="alert-title"><b></b>推荐结果<b></b></div>
                    <div className="alert-content">
                        <table>
                            <tbody>
                                <tr>
                                    <td>推荐用户注册</td>
                                    <td><span className="fc-main" ref="recommendUser">{_this.state.recommendCode.recomUser?_this.state.recommendCode.recomUser:0}</span> 人</td>
                                </tr>
                                <tr>
                                    <td>推荐用户投资</td>
                                    <td><span className="fc-main" ref="recommendInvest">{_this.state.recommendCode.recomInvest?_this.state.recommendCode.recomInvest:0}</span> 笔</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </Layer>
            </div>
        )
    }
});
module.exports = UserInfo;